



use "thetas15_alpha3_beta001_all_both_collapsed2013.dta", clear





			
merge 1:1 countryid year using complete_main_new.dtadrop _mergemerge 1:1 countryid year using eventdata						quietly gen conflict = bdbest25	
quietly gen conflict1000 = bdbest1000	sort countryid year
                        
                        generate one_before=conflict==0&F1.conflict==1generate two_before=conflict==0&(F1.conflict==1|F2.conflict==1)generate one_before1000=conflict1000==0&F1.conflict1000==1	by countryid: egen total_conflict = sum(conflict)drop _mergedrop countrymerge m:1 countryid using countryids.dtadrop _merge


gen xconsthigh =xconst==7gen xrcomphigh =xrcomp==3gen xropenhigh =xropen==4replace polity2 =0 if polity2==. & xconst!=.tabulate democracy, gen(democ_)generate armedconf4 = contig_bdbest25>3replace armedconf4 = . if contig_bdbest25==.replace armedconf4 = . if bdbest25==.generate lngdp = ln(rgdpl)
					tsset countryid year    generate growth = (rgdpl-L1.rgdpl)/L1.rgdpldrop avpopbysort countryid: egen avpop=mean(pop)drop if avpop==.drop if avpop<1000replace pop = ln(pop)

		egen regionid = group(subregion_o)

	
quietly tabulate year, gen(year_)
quietly tabulate country, gen(country_)

forval t = 0 / 14 {
	replace ste_theta`t'=L1.ste_theta`t' if L1.ste_theta`t'!=. & ste_theta`t'==. & year <= `t1'+1
}


rename ste_theta0 industry
rename ste_theta1 civlife
rename ste_theta2 asia
rename ste_theta3 sports
rename ste_theta4 justice
rename ste_theta5 tourism
rename ste_theta6 politics
rename ste_theta7 conflict1
rename ste_theta8 business
rename ste_theta9 economics
rename ste_theta10 in_relations2
rename ste_theta11 int_relations1
rename ste_theta12 middleast
rename ste_theta13 civlife2
rename ste_theta14 conflict2

summarize high low

generate high_dum = high>0
replace high_dum = . if high==.

generate low_dum = low>0
replace low_dum =. if low==.


local words "industry-conflict2"

local cFE = "country_*"
local tFE = "year_*"




*predict civil war with long list of variables including bdbest25
		
local standard "bdbest25 cha_count total_count total_count_count autoc democ democ_3 democ_4 democ_5 democ_6 armedconf4 contig_bdbest25 lnchildmortality discrimshare excludedshare high low"



local cFE = "country_*"
local tFE = "year_*"

replace one_before1000=. if conflict1000==1


lassoShooting one_before1000 `words' `standard',  controls(`cFE') lambda(100) lasiter(100) verbose(0) fdisplay(1) 
local wSel `r(selected)'
di "`wSel'"

local selection1 `r(selected)'

xtreg one_before1000 `wSel',fe r
matrix betas1 = e(b)
matrix list betas1
outreg2 using lassoselected, excel replace
		

lassoShooting one_before1000 `words' `standard',  controls(`cFE') lambda(150) lasiter(100) verbose(0) fdisplay(1) 
local wSel `r(selected)'
di "`wSel'"

local selection1 `r(selected)'

xtreg one_before1000 `wSel',fe r
matrix betas1 = e(b)
matrix list betas1
outreg2 using lassoselected, excel



lassoShooting one_before1000 `words' `standard',  controls(`cFE') lambda(200) lasiter(100) verbose(0) fdisplay(1) 
local wSel `r(selected)'
di "`wSel'"

local selection1 `r(selected)'

xtreg one_before1000 `wSel',fe r
matrix betas1 = e(b)
matrix list betas1
outreg2 using lassoselected, excel





local standard  "cha_count total_count total_count_count autoc democ democ_3 democ_4 democ_5 democ_6 armedconf4 contig_bdbest25 lnchildmortality discrimshare excludedshare high low"

replace one_before=. if conflict==1

lassoShooting one_before `standard' `words',  controls(`cFE') lambda(100) lasiter(100) verbose(0) fdisplay(1) 
local wSel `r(selected)'
di "`wSel'"

local selection1 `r(selected)'

xtreg one_before `wSel',fe r
matrix betas1 = e(b)
matrix list betas1
outreg2 using lassoselected, excel
		

lassoShooting one_before `standard' `words',  controls(`cFE') lambda(150) lasiter(100) verbose(0) fdisplay(1) 
local wSel `r(selected)'
di "`wSel'"

local selection1 `r(selected)'

xtreg one_before `wSel',fe r
matrix betas1 = e(b)
matrix list betas1
outreg2 using lassoselected, excel


lassoShooting one_before `standard' `words',  controls(`cFE') lambda(200) lasiter(100) verbose(0) fdisplay(1) 
local wSel `r(selected)'
di "`wSel'"

local selection1 `r(selected)'

xtreg one_before `wSel',fe r
matrix betas1 = e(b)
matrix list betas1
outreg2 using lassoselected, excel


